# USAGE:
# curl -o dev_alpine.dockerfile https://gitee.com/codesprite/gist/raw/master/dev_alpine.dockerfile
# docker build -t dev_alpine -f dev_alpine.dockerfile .
# docker kill <container_name> && docker rm <container_name>
# docker run -d -p xx:80 -v xx:/root/.ssh -v xx:/root/app -h <container_name> --name <container_name> dev_alpine

FROM alpine

# source in China
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

# install git tools
RUN apk add --no-cache openssh-client git \
    && git config --global user.email "68074108@qq.com" \
    && git config --global user.name "Megrez"

# install oh-my-zsh and set zsh default shell
RUN apk add --no-cache curl zsh \
    && git clone https://gitee.com/mirrors/oh-my-zsh.git ~/.oh-my-zsh \
    && cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc \
    && sed -i 's/ZSH_THEME=\"robbyrussell\"/ZSH_THEME=\"my\"/' ~/.zshrc \
    && sed -i 's/# DISABLE_AUTO_UPDATE/DISABLE_AUTO_UPDATE/' ~/.zshrc \
    && sed -i 's/ash/zsh/' /etc/passwd \
    && curl -o ~/.oh-my-zsh/themes/my.zsh-theme https://gitee.com/codesprite/gist/raw/master/my.zsh-theme

# set time zone
RUN apk add --no-cache tzdata \
    && echo -e "\nexport TZ="Asia/Shanghai"\n" >> /root/.zshrc
ENV TZ="Asia/Shanghai"

# install supervisor
RUN apk add --no-cache supervisor \
    && mkdir -p /var/log/supervisor \
    && sed -i 's/\[supervisord\]/\[supervisord\]\nnodaemon=true/' /etc/supervisord.conf \
    && sed -i 's/files = .*/files = \/root\/app\/*.supervisor\n/' /etc/supervisord.conf

CMD ["/usr/bin/supervisord"]

# install python3 
RUN apk add --no-cache python3 python3-dev py3-pip \
    && mkdir /root/.pip \
    && echo "[global]" >> /root/.pip/pip.conf \
    && echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple" >> /root/.pip/pip.conf \
    && pip install --upgrade pip \
    && pip install pipenv

# install useful tools
RUN apk add --no-cache go g++ \
    && go env -w GOPROXY=https://goproxy.cn